package com.mengshuai.mysql.controller;

import com.mengshuai.mysql.bean.Person;
import com.mengshuai.mysql.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * person控制器
 *
 * @author 孟帅
 * @since 2024/11/15
 */
@RestController
@RequestMapping("/person")
public class PersonController {
    @Autowired
    private IPersonService personService;

    @GetMapping("/getPersonById")
    public Person getPersonById(@RequestParam int id){
        return personService.getPersonById(id);
    }

    @PostMapping("/insert")
    public String insert(@RequestBody Person person){
        personService.insert(person);
        return "插入成功";
    }

    @PostMapping("/insert1")
    public String insert1(@RequestBody Person person){
        personService.insert1(person);
        return "插入成功";
    }
}
